$title Basic model

$ontext
--------------------------------------------------------------------------------
Closed 2x2 economy.
Laurent Cretegny, CoPS, Monash University, Australia, 2003.
--------------------------------------------------------------------------------
$offtext

$set path d:\prof\research\mpsge\mge2gem\examples\mpsge\basic

sets
  o                 commodity and sector          / agr, ind /
  f                 primary factor                / lab, cap /;

alias(o,s);

parameters
  sam(*,*)          benchmark social accounting matrix
  factor(f,s)       factor demand
  demand(o)         demand for consumption
  endow(f)          endowment
  supply(s)         supply of output
  cons              aggregate consumption;

$call gdxxrw i=%path%\basic.xls o=%path%\basic.gdx index=declare
$gdxin %path%\basic.gdx
$load sam = sam
$gdxin

factor(f,s) = sam(f,s);
demand(o) = sam(o,"ra");
endow(f) = sam("ra",f);
supply(s) = sum(f, factor(f,s));
cons = sum(o, demand(o));

$ontext
$model:basic

$sectors:
  y(s)              ! production
  c                 ! aggregate consumption

$commodities:
  p(o)              ! price of commodity
  pc                ! price of aggregate consumption
  pf(f)             ! price of primary factor

$consumers:
  ra                ! representative agent income

$prod:y(s)          s:1.0
  o:p(s)            q:supply(s)
  i:pf(f)           q:factor(f,s)

$prod:c             s:1.0
  o:pc              q:cons
  i:p(o)            q:demand(o)

$demand:ra
  d:pc              q:cons
  e:pf(f)           q:endow(f)

$report:
  v:r_cons(o)       i:p(o)              prod:c

$offtext
$sysinclude mpsgeset basic

* Benchmark replication

basic.iterlim = 0;
$include basic.gen
solve basic using mcp;
abort$(abs(basic.objval) gt 1e-8) "*** basic does not calibrate ! ***";
basic.iterlim = 1000;

* Fixation of a numeraire to allow comparison

ra.fx = ra.l;

* Counterfactual : 50% increase in labor endowment

endow("lab") = 1.5 * endow("lab");

$include basic.gen
solve basic using mcp;

* Results

parameters
  res_com           results by commodity in % change from basis
  res_agg           aggregate results in % change from basis; 

res_com("output",o) = (y.l(o) - 1) * 100;
res_com("cons",o) = (r_cons.l(o)/demand(o) - 1) * 100;
res_com("price",o) = (p.l(o) - 1) * 100;

res_agg("c") = (c.l - 1 ) * 100;
res_agg("pc") = (pc.l - 1 ) * 100;
res_agg("ra_inc") = (ra.l/cons - 1 ) * 100;

option decimals = 6;
display res_com, res_agg;
